﻿using System;
using Newtonsoft.Json.Linq;
using Shanbay.Model;

namespace Shanbay.Core
{
    public class ShanbayPage: System.Web.UI.Page
    {
        private string redirect_uri = "http://liuxing.bid/bay/Tranurl.html";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetToken() == null)
            {
                JObject obj = new JObject();
                obj.Add("success","false");
                obj.Add("err_code",1);
                obj.Add("msg","未登陆");
                obj.Add("url", "https://api.shanbay.com/oauth2/authorize/?client_id=a43d99e58c5c947d6df7&response_type=token&redirect_uri=" + redirect_uri);
                Response.Write(obj.ToString());
            }
            else
            {
                InitPage();
            }
        }

        protected virtual void InitPage()
        {

        }

        protected SToken GetToken()
        {
            return Session["Shanbay"] as SToken;
        }

       protected void SetToken(SToken token)
        {
            Session["Shanbay"] = token;
        }
    }
}
